#include <Uefi.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>

#include "../../Driver/SimpleCalculationProtocol/SimpleCalculation.h"

EFI_STATUS
EFIAPI
UefiMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE  *SystemTable)
{
  EFI_STATUS                          Status;
  EFI_SIMPLE_CALCULATION_PROTOCOL     *SimpleCalculation;
  UINTN                               A = 20;
  UINTN                               B = 10;
  UINTN                               Result;

  // Locate the Simple Calculation Protocol
  Status = gBS->LocateProtocol(&gEfiSimpleCalculationProtocolGuid, NULL, (VOID**)&SimpleCalculation);
  if (EFI_ERROR(Status)) {
    Print(L"Failed to locate Simple Calculation Protocol: %r\n", Status);
    return Status;
  }

  // Perform Addition
  Status = SimpleCalculation->Add(SimpleCalculation, A, B, &Result);
  if (!EFI_ERROR(Status)) {
    Print(L"%u + %u = %u\n", A, B, Result);
  }

  // Perform Subtraction
  Status = SimpleCalculation->Subtract(SimpleCalculation, A, B, &Result);
  if (!EFI_ERROR(Status)) {
    Print(L"%u - %u = %u\n", A, B, Result);
  }

  // Perform Multiplication
  Status = SimpleCalculation->Multiply(SimpleCalculation, A, B, &Result);
  if (!EFI_ERROR(Status)) {
    Print(L"%u * %u = %u\n", A, B, Result);
  }

  // Perform Division
  Status = SimpleCalculation->Divide(SimpleCalculation, A, B, &Result);
  if (!EFI_ERROR(Status)) {
    Print(L"%u / %u = %u\n", A, B, Result);
  }

  return EFI_SUCCESS;
}